<template>
  <div class="block">
    <ElTimeline>
      <ElTimelineItem
          :timestamp="activity.pushtime"
          placement="top"
          v-for="(activity, index) in activities"
          :key="index"
          color="#0bbd87"
      >
        <ElCard>
          <h3>{{ activity.author }}</h3>
          <h4>{{ activity.content }}</h4>
          <p></p>
        </ElCard>
      </ElTimelineItem>
    </ElTimeline>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';
import { ElTimeline, ElTimelineItem, ElCard } from 'element-plus';

const activities = ref([{
  author: "",
  content: '',
  pushtime: ''
}]);

const fetchOneWord = async () => {
  try {
    const result = await axios.get('/ky/user/oneword');
    activities.value = result.data.data;
  } catch (error) {
    console.error('获取数据时出错:', error);
  }
};

onMounted(() => {
  fetchOneWord();
});
</script>

<style>
.a {
  color: rgb(74, 74, 182);
}
</style>